package com.redstars.generate.controller;


import com.redstars.generate.page.PageResult;
import com.redstars.generate.result.Result;
import lombok.AllArgsConstructor;
import com.redstars.generate.service.SysTemplateVersionService;
import com.redstars.generate.query.SysTemplateVersionQuery;
import com.redstars.generate.vo.SysTemplateVersionVo;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;

/**
* 模板版本
*
* @author zhouhx 
* @since 1.0.0 2022-10-26
*/
@RestController
@RequestMapping("gen/templateVersion")
@AllArgsConstructor
public class SysTemplateVersionController {
    private final SysTemplateVersionService sysTemplateVersionService;

    @GetMapping("page")
    public Result<PageResult<SysTemplateVersionVo>> page(@Valid SysTemplateVersionQuery query){
        PageResult<SysTemplateVersionVo> page = sysTemplateVersionService.page(query);

        return Result.ok(page);
    }

    @GetMapping("list")
    public Result<List<SysTemplateVersionVo>> list(SysTemplateVersionQuery query){
        List<SysTemplateVersionVo> list = sysTemplateVersionService.list(query);

        return Result.ok(list);
    }

    @GetMapping("detail")
    public Result<SysTemplateVersionVo> detail(SysTemplateVersionQuery query){
        SysTemplateVersionVo detail = sysTemplateVersionService.detail(query);

        return Result.ok(detail);
    }

    @PostMapping("save")
    public Result<String> save(@RequestBody SysTemplateVersionVo vo){
        sysTemplateVersionService.save(vo);

        return Result.ok();
    }

    @PutMapping("update")
    public Result<String> update(@RequestBody @Valid SysTemplateVersionVo vo){
        sysTemplateVersionService.update(vo);

        return Result.ok();
    }

    @DeleteMapping("delete")
    public Result<String> delete(@RequestBody List<Long> idList){
        sysTemplateVersionService.delete(idList);

        return Result.ok();
    }

}